// $Id: log.h 67 2011-04-23 15:35:40Z cedric.shih@gmail.com $
/*
 * Copyright (C) 2010 Cedric Shih <cedric.shih@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef LOG_H_
#define LOG_H_

#include <stdarg.h>

#include "niohttpd.h"

#ifdef __GNUC__
#define NIOHTTPD_CHECK_FMT(a,b) __attribute__((format(printf, a, b)))
#else
#define NIOHTTPD_CHECK_FMT(a,b)
#endif

#define niohttpd_trace(fmt...) niohttpd_log(NIO_TRACE, __func__, __LINE__, fmt)
#define niohttpd_debug(fmt...) niohttpd_log(NIO_DEBUG, __func__, __LINE__, fmt)
#define niohttpd_info(fmt...) niohttpd_log(NIO_INFO, __func__, __LINE__, fmt)
#define niohttpd_warn(fmt...) niohttpd_log(NIO_WARN, __func__, __LINE__, fmt)
#define niohttpd_error(fmt...) niohttpd_log(NIO_ERROR, __func__, __LINE__, fmt)
#define niohttpd_fatal(fmt...) niohttpd_log(NIO_FATAL, __func__, __LINE__, fmt)

void niohttpd_log(enum niolog_level level,
		const char *func, unsigned int line,
		const char *fmt, ...) NIOHTTPD_CHECK_FMT(4,5);

#endif /* LOG_H_ */
